<template>
	<view class="question-container tn-flex">
		<view class="avatar">
			<tn-avatar src="https://resource.tuniaokj.com/images/avatar/xiaomai4.jpg" size="sm"></tn-avatar>
		</view>
		<view class="content">
			<view class="user-name">
				<text>旅行规划大师</text>
			</view>
			<view class="message">
				<zero-markdown-view :markdown="msgContent"></zero-markdown-view>
				<image v-show="message.flag === 'current' && replying"  src="https://ai-agent-oss.oss-cn-beijing.aliyuncs.com/loading_moon.apng" class="cursor" mode="aspectFit"></image>
			</view>
		</view>
	</view>
</template>

<script>
import message from '../../../tuniao-ui/libs/function/message'
	export default {
		data() {
			return {
			}
		},
		props: {
			message: {
				type: Object,
				default: function () {
					return {}
				}
			},
			replying: {
				type: Boolean,
				default: false
			}
		},
		computed: {
			// 流式输出时代码块处理 , 这时候请使用 msgContent 传入组件中
			msgContent() {
				if (!this.message.content) {
					return;
				}
				let htmlString = "";
				// 判断markdown中代码块标识符的数量是否为偶数
				if (this.message.content.split("```").length % 2) {
					let content = this.message.content;
					if (content[content.length - 1] != "\n") {
						content += "\n";
					}
					htmlString = content;
				} else {
					htmlString = this.message.content;
				}
				return htmlString;
			},
		},
		watch: {
		},
		methods: {
			
		}
	}
</script>

<style lang="scss" scoped>
	.avatar {
		margin-right: 20rpx;
		border-radius: 50%;
	}
	.content {
		.user-name {
			margin-bottom: 10rpx;
			color: #06070980;
		}
		.message {
			background-color: #f5f5f5;
			color: #060709cc;
			border-radius: 16rpx;
			padding: 24rpx 32rpx 24rpx 10rpx;
			.cursor {
				width: 48rpx;
				height: 48rpx;
			}
		}
	}
</style>